package com.loveazure.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.HashMap;

public class SymbolConvert {

	private HashMap<Character, Character> map=new HashMap<Character, Character>();

	public SymbolConvert() {
		File file = new File("src/PSymbolConvert");
		FileReader fr;
		String line;
		try {
			fr = new FileReader(file);
			BufferedReader br = new BufferedReader(fr);
			while ((line = br.readLine()) != null) {
				if (line.length() == 3) {
					map.put(line.charAt(0), line.charAt(2));
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	public String convert(String s) {
		StringBuffer retsb = new StringBuffer();
		char[] ch = s.toCharArray();
		for (char c : ch) {
			if (map.containsKey(c)) {
				retsb.append(map.get(c));
			} else {
				retsb.append(c);
			}
		}
		return retsb.toString();
	}
}
